package com.tuda.system.service.impl;

import com.tuda.common.core.domain.R;
import com.tuda.common.utils.ToolUtil;
import com.tuda.system.domain.TudaRegion;
import com.tuda.system.mapper.TudaRegionMapper;
import com.tuda.system.service.ITudaRegionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName RegionServiceImpl
 * @Description TODO
 * @Author Admin
 * @Date 2023/7/17 10:50
 * @Version 1.0
 **/
@Service
public class TudaRegionServiceImpl implements ITudaRegionService {

    @Resource
    private TudaRegionMapper tudaRegionMapper;

    @Override
    public R<List<TudaRegion>> threeLevelLink(String parentId, Integer level) {
        parentId = ToolUtil.isEmpty(parentId) ? "0" : parentId;
        if (level != 1 && ToolUtil.isEmpty(parentId)) {
            return R.fail("parentId传值错误");
        }
        Long parentIdL = Long.parseLong(parentId);
        return R.ok(tudaRegionMapper.threeLevelLink(parentIdL, level));
    }
}
